package com.basker.pisces.auth.service.api;

import javax.validation.Valid;

import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.basker.pisces.auth.service.pojo.ChangePasswordRequest;
import com.basker.pisces.auth.service.pojo.LoginRequest;
import com.basker.pisces.auth.service.pojo.LoginResult;
import com.basker.pisces.auth.service.pojo.RegistRequest;
import com.basker.pisces.context.LoginContext;
import com.basker.pisces.service.annotation.IgnoreLoginContext;
import com.basker.pisces.service.dto.DefaultServiceResult;

@RestController
@RequestMapping("/auth")
public interface IAuthService {

    /**
     * 无效令牌的错误码
     */
    static final int INVALID_TOKEN_STATUS = 1002;

    /**
     * 已注册的错误码
     */
    static final int ALREADY_REGISTED = 1001;

    static final String TOKEN_ID_KEY = "tokenId";

    @PostMapping("/changePassword")
    DefaultServiceResult<Void> changePassword(@Valid @RequestBody ChangePasswordRequest request);

    @PostMapping("/identify")
    DefaultServiceResult<LoginContext> identify();

    @IgnoreLoginContext
    @PostMapping("/login")
    DefaultServiceResult<LoginResult> login(@Valid @RequestBody LoginRequest request);

    @PostMapping("/logout")
    DefaultServiceResult<Void> logout();

    @IgnoreLoginContext
    @PostMapping("/regist")
    DefaultServiceResult<Long> regist(@Valid @RequestBody RegistRequest request);
}
